//将原型中的声明放入构造函数中(需一次判断)

function Person(name, age, friends){
    this.name = name;
    this.age = age;
    this.friends = friends;
    
    if(typeof this.say != "function"){ //在原型声明方法(只会执行第一次)
        alert("执行");
        Person.prototype.say = function(){
            alert(this.friends);
        }
    }
}


var p1 = new Person("小明", 18, ["张三", "李四"]);
p1.say();
var p2 = new Person();//这次实例化对象没有触发"执行"
p2.say();